// 判断是不是iphone设备
const isIphonex = () => {  // X XS, XS Max, XR
  const xSeriesConfig = [
    {
      devicePixelRatio: 3,
      width: 375,
      height: 812,
    },
    {
      devicePixelRatio: 3,
      width: 414,
      height: 896,
    },
    {
      devicePixelRatio: 2,
      width: 414,
      height: 896,
    },
  ];  // h5
  if (typeof window !== 'undefined' && window) {
    const isIOS = /iphone/gi.test(window.navigator.userAgent);
    if (!isIOS) return false;
    const { devicePixelRatio, screen } = window;
    const { width, height } = screen;
    return xSeriesConfig.some(item => item.devicePixelRatio === devicePixelRatio && item.width === width && item.height === height);
  }
  return false;
}

// 判断是是不是app环境
function getIsApp() {
  var ua = navigator.userAgent.toLowerCase();
  if (ua.match(/isapp/i) == "isapp") {
    return true;
  }
  return false;
};

// && getIsApp()
// if (isIphonex()) {
//   $("html").css("paddingTop", "43px");
//   $('body').css('backgroundClip', 'padding-box');
// }


function judgeBrand(sUserAgent) {
  var isIphone = sUserAgent.match(/iphone/i) == "iphone";
  var isHuawei = sUserAgent.match(/huawei/i) == "huawei";
  var isHonor = sUserAgent.match(/honor/i) == "honor";
  var isOppo = sUserAgent.match(/oppo/i) == "oppo";
  var isOppoR15 = sUserAgent.match(/pacm00/i) == "pacm00";
  var isVivo = sUserAgent.match(/vivo/i) == "vivo";
  var isXiaomi = sUserAgent.match(/mi\s/i) == "mi ";
  var isXiaomi2s = sUserAgent.match(/mix\s/i) == "mix ";
  var isRedmi = sUserAgent.match(/redmi/i) == "redmi";
  var isSamsung = sUserAgent.match(/sm-/i) == "sm-";

  if (isIphone) {
    return 'iphone';
  } else if (isHuawei || isHonor) {
    return 'huawei';
  } else if (isOppo || isOppoR15) {
    return 'oppo';
  } else if (isVivo) {
    return 'vivo';
  } else if (isXiaomi || isRedmi || isXiaomi2s) {
    return 'xiaomi';
  } else if (isSamsung) {
    return 'samsung';
  } else {
    return 'default';
  }
}
var brand = judgeBrand(navigator.userAgent.toLowerCase());
// if (brand == 'huawei' || brand == 'iphone') {
//   $("html").css("paddingTop", "43px");
//   $(".headerTop").css("top", "43px");
// }
